﻿using MaterialDesignThemes.Wpf;
using System.Windows.Controls;

namespace GameView.Comment
{
    public interface IDialogService
    {
        Task ShowDialog<TView>() where TView : UserControl;

        Task<object> ShowDialog<TView>(TView view) where TView : UserControl;

        Task<object> ShowDialog<TView>(TView view, string Owner) where TView : UserControl;

        Task ShowDialog<TView>(string Owner) where TView : UserControl;
    }

    public class DialogService : IDialogService
    {
        public async Task ShowDialog<TView>() where TView : UserControl
        {
            var view = ExtentHelper.GetService<TView>();
            await DialogHost.Show(view, "RootDialog");
        }

        public async Task<object> ShowDialog<TView>(TView view) where TView : UserControl
        {
            return await DialogHost.Show(view, "RootDialog");
        }

        public async Task ShowDialog<TView>(string Owner) where TView : UserControl
        {
            var view = ExtentHelper.GetService<TView>();
            await DialogHost.Show(view, Owner);
        }

        public async Task<object> ShowDialog<TView>(TView view, string Owner) where TView : UserControl
        {
            return await DialogHost.Show(view, Owner);
        }
    }
}